package com.galaxy.nebula.account.bo.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;

import com.galaxy.nebula.account.bo.IAccountBO;
import com.galaxy.nebula.account.dao.IAccountDAO;
import com.galaxy.nebula.account.model.Account;

public class AccountBOImpl implements IAccountBO {

    private IAccountDAO accountDAOImpl;

    @Autowired
    public void setAccountDAOImpl(IAccountDAO accountDAOImpl) {
        this.accountDAOImpl = accountDAOImpl;
    }
    
    @Override
    public Account findAccountById(Long id) throws Exception {
        return accountDAOImpl.findAccountById(id);
    }

    @Override
    public Account insertAccount(Account account) throws Exception {
        if (account == null) {
            return null;
        }
        account.setId(accountDAOImpl.accountSeq());
        account.setAvailableAmt(account.getEnrollAmt());
        account.setModifydate(new Date());
        account.setCreatedate(new Date());
        return accountDAOImpl.insertAccount(account);
    }

    @Override
    public int updateAccount(Account account) throws Exception {
        return accountDAOImpl.updateAccount(account);
    }

}
